Repository navigation
fix(studio): a sealed picker edit answered after another pick leaves the new pick's state alone - #8686
Merged
Conversation
…the new pick's state alone
Contributor
Edit accuracy: accurate 273 (base branch 271), smooth 59 of thoseThe gate passes. Newly passing (2)
Not banked yet, reported and not gated (bank a full-grid run's baseline.json) (2)
Quarantined, measured but not gated (0) |
jrusso1020
approved these changes
Nov 24, 2026
jrusso1020
left a comment
Collaborator
There was a problem hiding this comment.
Approving at 24a66766.
- The fix holds. In
writePickedElement, the sealed answer's state update now runs only when the current pick has the same selector and id as the pick the edit was made on. Otherwise the state is left alone. The source save still uses thepickedcaptured at edit time, so the late edit still lands on its own element. - Red-first holds. With main's
useElementPicker.tsput back, the named test "a sealed edit answered after another pick saves to its own element and leaves the new pick alone" fails withexpected 'red' to be undefined(1 failed, 1 passed). At head,useElementPicker.sealed.test.tsanduseElementPicker.test.tspass (31/31). - I added probes with the same harness, each with
writePickedheld open:- A, then B, then A again, then A's answer: the color shows on the re-picked A, and the file gets
style="color: red"on theh1. That's correct, because the frame drew the edit on that element. Keying on the element (selector and id) instead of on each pick is the right call here: a per-pick key would drop an update the frame really drew. - Same element picked again before the answer: the edit still shows.
- Current pick's edit applies while an old pick's edit is still open: pick
h1and set red, pickpand set blue, answerpfirst and thenh1. The pick stayspwith blue, and the file ends with red on theh1and blue on thep. Nothing legitimate is dropped. - A
nullanswer (nothing drawn): the state is unchanged.
- A, then B, then A again, then A's answer: the color shows on the re-picked A, and the file gets
Nit, not from this PR:
- Two edits on the same pick whose answers come back in reverse order leave the pick showing the older value. For example, set red, then blue, answer blue first and then red, and the final color is red. Main does the same, and the preview channel likely answers in order, so this probably can't happen in practice. I haven't verified that the channel guarantees the order.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A sealed picker edit that lands after the person has already picked another element now leaves the new pick's state alone. The edit still saves to the element it was made on.
Why
Follow-up to #8663 (review nits 2 and 3). In a sealed preview,
setStyle,setDataAttrandsetTextContentwait for the frame to draw before they update the picker state. The update wasprev ? shown(prev) : null, so if another element was picked in the meantime, the old edit's style, attribute or text was written onto the new pick's state. The source save was already right: it uses the element captured when the edit was made.Related work
Refs #8663.
How
useElementPicker'swritePickedElement, the state update applies only while the same element is still picked (samePick: same selector and id). Otherwise the state is left as it is. Unsealed, the update runs synchronously, so the pick cannot have changed and nothing changes there.writePicked).useElementPicker.sealed.test.tsnow tests it withwritePickedheld open until the test answers.Test plan
packages/studio/src/hooks/useElementPicker.sealed.test.ts:h1, set a color, pickp, then let the frame answer. The pick is stillp, its styles have no color, and the saved file hasstyle="color: red"on theh1.h1show on the pick only once answered, and both show.Devbox: the named test passed 3 runs in a row (exit 0, 2 passed), the covering
useElementPicker.test.tspassed, and studiotsc, Fallow and pre-push were clean.fails without the fix:
useElementPicker.sealed.test.ts"a sealed edit answered after another pick saves to its own element and leaves the new pick alone". With #8663's update restored (prev ? shown(prev) : null), it fails withexpected 'red' to be undefined(exit 1, 1 failed, 1 passed). The ordering test stays green.No visible change
No Studio or Desktop screen calls these setters (see #8663), and the change is in
.tsfiles only.